﻿<%@ Page Title="" Language="C#" MasterPageFile="~/administrator/backend.Master" AutoEventWireup="true" CodeBehind="truong-add.aspx.cs" Inherits="VQWEB.administrator.huongnghiep.truong.truong_add" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content_backend" runat="server">
<form id="frmObjects" action="" method="post">
<div id="formadd" class="row">
    <div class="col-md-8">
    <div id="col8" class="row"></div>
    <div id="formtab" class="row">
 <ul class="nav nav-tabs" id="ConfigsTab" style="margin-bottom: 0px">
        <li class="active"><a href="#tab1" data-toggle="tab">Nhóm 1</a></li>
        <li><a href="#tab2" data-toggle="tab">Nhóm 2</a></li>
        <li><a href="#tab3" data-toggle="tab">Nhóm 3</a></li>        
        <li><a href="#tab4" data-toggle="tab">Nhóm 4</a></li>
        <li><a href="#tab5" data-toggle="tab">Nhóm 5</a></li>
    </ul>
    <div class="tab-content" style="border-left: 1px solid #DDDDDD; border-right: 1px solid #DDDDDD;
        border-bottom: 1px solid #DDDDDD; padding: 15px">
        <div id="tab1" class="tab-pane active">
        </div>
        <div id="tab2" class="tab-pane" >
        </div>
        <div id="tab3" class="tab-pane">
        </div>       
        <div id="tab4" class="tab-pane">
        </div>
         <div id="tab5" class="tab-pane">
        </div>
    </div>
</div>
    </div>
    <div id="col4" class="col-md-4"></div>
</div>

    </form>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Script_backend" runat="server">
    <script type="text/javascript">
        ShowToolBar("edit");
        var url_ashx = "/admin/huongnghiep/truong/handler";
        var url_input = '<%=ResolveUrl("~/administrator/templates/input.tpl") %>';

        $(document).ready(function () {
            $.get(url_ashx, { view_truong: "view_truong", Id: GetId() }, function (data) {
                var parse = $.parseJSON(data);
                var chuyennganh = parse.chuyennganh;
                var khoi = parse.khoi;
                var hedaotao = parse.hedaotao;
                var array_chuyennganh, array_khoi, array_hedaotao;
                if (CheckAtionInPath("add")) {
                    array_hedaotao = array_checkbox(hedaotao);
                    array_khoi = array_checkbox(khoi);
                    array_chuyennganh = array_select(chuyennganh);
                    loadform(0, "", "", "", "", "", "","", "", "", "",
                "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",0,false,
                 false, array_hedaotao, array_khoi, array_chuyennganh);
                }
                else if (CheckAtionInPath("edit")) {
                    var truong = parse.truong;
                    var hedaotao = parse.hedaotao;
                    var khoi = parse.khoi;
                    var chuyennganh = parse.chuyennganh;
                    array_hedaotao = array_checkbox(hedaotao);
                    array_khoi = array_checkbox(khoi);
                    array_chuyennganh = array_select(chuyennganh);
                    loadform(truong.id, truong.ma, truong.ten, truong.gioithieu, truong.logo, truong.diachi, truong.website,truong.email, truong.dienthoai,
                     truong.bosung0, truong.bosung1, truong.bosung2, truong.bosung3, truong.bosung4, truong.bosung5, truong.bosung6, truong.bosung7,
                     truong.bosung8, truong.bosung9, truong.bosung10, truong.bosung11, truong.bosung12, truong.bosung13, truong.bosung14, truong.bosung15,
                     truong.bosung16, truong.bosung17, truong.bosung18, truong.bosung19, truong.bosung20, truong.bosung21, truong.bosung22, truong.bosung23,
                     truong.bosung24, truong.bosung25, truong.bosung26, truong.bosung27, truong.bosung28, truong.bosung29, truong.bosung30,
                     truong.hit, truong.ishome, truong.active, array_hedaotao, array_khoi, array_chuyennganh);
                }
            });
        });

    function loadform(id, ma, ten, gioithieu, logo, diachi, website,email, dienthoai, bosung0, bosung1, bosung2, bosung3, bosung4, bosung5, bosung6, bosung7,
     bosung8, bosung9, bosung10, bosung11, bosung12, bosung13, bosung14, bosung15,bosung16, bosung17, bosung18, bosung19, bosung20, bosung21, bosung22, bosung23,
     bosung24, bosung25, bosung26, bosung27, bosung28, bosung29, bosung30, hit, ishome, active, array_hedaotao, array_khoi, array_chuyennganh) {
        $.jqoteload(url_input, function (tmpl) {
            $("#col4").multiple("groupcheckbox", "hedaotao_array_id[]", array_hedaotao, "Hệ đào tạo:", tmpl.input_tpl);
            $("#col4").multiple("groupcheckbox", "khoi_array_id[]", array_khoi, "Khối:", tmpl.input_tpl);
            $("#col4").multiple("multiselect", "chuyennganh_array_id[]", array_chuyennganh, "Chuyên ngành:", tmpl.input_tpl);
            $("#col8").single("hidden", "truong_id", id, null, null, tmpl.input_tpl);
            $("#col8").single("text", "truong_ten", ten, "Tên Trường:", null, tmpl.input_tpl);
            $("#col8").single("text", "truong_ma", ma, "Mã trường:", null, tmpl.input_tpl);
            $("#col8").single("editor", "truong_gioithieu", gioithieu, "Giới thiệu:", null, tmpl.input_tpl);
            $("#col4").single("text", "truong_logo", logo, "Logo:", null, tmpl.input_tpl);
            $("#col4").single("text", "truong_diachi", diachi, "Địa chỉ:", null, tmpl.input_tpl);
            $("#col4").single("text", "truong_website", website, "Website:", null, tmpl.input_tpl);
            $("#col4").single("text", "truong_email", email, "Email:", null, tmpl.input_tpl);
            $("#col4").single("text", "truong_dienthoai", dienthoai, "Điện thoại:", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_0", bosung0, "Trường bổ sung 0 :", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_1", bosung1, "Trường bổ sung 1:", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_2", bosung2, "Trường bổ sung 2:", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_3", bosung3, "Trường bổ sung 3:", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_4", bosung4, "Trường bổ sung 4:", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_5", bosung5, "Trường bổ sung 5:", null, tmpl.input_tpl);
            $("#tab1").single("text", "truong_bosung_6", bosung6, "Trường bổ sung 6:", null, tmpl.input_tpl);
            $("#tab2").single("text", "truong_bosung_7", bosung7, "Trường bổ sung 7:", null, tmpl.input_tpl);
            $("#tab2").single("text", "truong_bosung_8", bosung8, "Trường bổ sung 8:", null, tmpl.input_tpl);
            $("#tab2").single("text", "truong_bosung_9", bosung9, "Trường bổ sung 9:", null, tmpl.input_tpl);
            $("#tab2").single("text", "truong_bosung_10", bosung10, "Trường bổ sung 10:", null, tmpl.input_tpl);
            $("#tab2").single("text", "truong_bosung_11", bosung11, "Trường bổ sung 11:", null, tmpl.input_tpl);
            $("#tab2").single("text", "truong_bosung_12", bosung12, "Trường bổ sung 12:", null, tmpl.input_tpl);
            $("#tab3").single("text", "truong_bosung_13", bosung13, "Trường bổ sung 13:", null, tmpl.input_tpl);
            $("#tab3").single("text", "truong_bosung_14", bosung14, "Trường bổ sung 14:", null, tmpl.input_tpl);
            $("#tab3").single("text", "truong_bosung_15", bosung15, "Trường bổ sung 15:", null, tmpl.input_tpl);
            $("#tab3").single("text", "truong_bosung_16", bosung16, "Trường bổ sung 16:", null, tmpl.input_tpl);
            $("#tab3").single("text", "truong_bosung_17", bosung17, "Trường bổ sung 17:", null, tmpl.input_tpl);
            $("#tab3").single("text", "truong_bosung_18", bosung18, "Trường bổ sung 18:", null, tmpl.input_tpl);
            $("#tab4").single("text", "truong_bosung_19", bosung19, "Trường bổ sung 19:", null, tmpl.input_tpl);
            $("#tab4").single("text", "truong_bosung_20", bosung20, "Trường bổ sung 20:", null, tmpl.input_tpl);
            $("#tab4").single("text", "truong_bosung_21", bosung21, "Trường bổ sung 21:", null, tmpl.input_tpl);
            $("#tab4").single("text", "truong_bosung_22", bosung22, "Trường bổ sung 22:", null, tmpl.input_tpl);
            $("#tab4").single("text", "truong_bosung_23", bosung23, "Trường bổ sung 23:", null, tmpl.input_tpl);
            $("#tab4").single("text", "truong_bosung_24", bosung24, "Trường bổ sung 24:", null, tmpl.input_tpl);
            $("#tab5").single("text", "truong_bosung_25", bosung25, "Trường bổ sung 25:", null, tmpl.input_tpl);
            $("#tab5").single("text", "truong_bosung_26", bosung26, "Trường bổ sung 26:", null, tmpl.input_tpl);
            $("#tab5").single("text", "truong_bosung_27", bosung27, "Trường bổ sung 27:", null, tmpl.input_tpl);
            $("#tab5").single("text", "truong_bosung_28", bosung28, "Trường bổ sung 28:", null, tmpl.input_tpl);
            $("#tab5").single("text", "truong_bosung_29", bosung29, "Trường bổ sung 29:", null, tmpl.input_tpl);
            $("#tab5").single("text", "truong_bosung_30", bosung30, "Trường bổ sung 30:", null, tmpl.input_tpl);
            $("#col4").single("text", "truong_hit", hit, "Lượt xem:", null, tmpl.input_tpl);
            $("#col4").single("checkbox", "truong_ishome", true, "Trang chủ", ishome, tmpl.input_tpl);
            $("#col4").single("checkbox", "truong_active", true, "Kích hoạt", active, tmpl.input_tpl);
            tinymce.init({ selector: 'textarea#tinymce' });
            $("#frmObjects").validate({
                rules: { truong_ten: { required: true }, truong_ma: {required: true} },
                messages: { truong_ten: { required: null }, truong_ma: { required: true} }
            });
            $("input[name='truong_dienthoai']").mask("99999999");
        });

        }

        $(document).on("click", "#btnCancel", function () {
            window.location = "/admin/huongnghiep/truong/list";
        });
        $(document).on("click", "#btnSave", function () {
            if ($("#frmObjects").valid()) {
                var value = tinymce.get('tinymce').getContent();
                $("textarea[name='truong_gioithieu']").val(value);
                var arr = $("#frmObjects").serializeObject();
                $.post(url_ashx, { add_truong: window.escape(arr) }, function (data) {
                    alert(data);
                    window.location = "/admin/huongnghiep/truong/list";
                });
            }
        });
    </script>
</asp:Content>
